﻿

namespace LxCFD
{
    public partial class ZoneCFDFields
    {
        public WallDistance WallDistance;
        public Value1FromArray1<double> GammaCommon;
        public void CreateFields_TurbBase(bool isSupportByParent)
        {
            bool advice = isSupportByParent && PhysicalModel.FlowType == FlowTypes.Turbulence;
            if (advice)
            {
                if (WallDistance == null)
                {
                    WallDistance = new WallDistance();
                    WallDistance.CheckCreate(Zone);
                }
                AppRes.SolveCenter.WallDistanceGroup.distanceInZone.Add(WallDistance);
                if (GammaCommon == null)
                {
                    GammaCommon = new Value1FromArray1<double>();
                    GammaCommon.setParameter(new double[Zone.Faces.Length]);
                }
            }
            else
            {
                WallDistance = null;
                GammaCommon = null;
            }
            CreateFields_kw(advice);
        }
        public void SetParameter_TurbBase()
        {
            if (WallDistance == null) return;
            int i1 = 0;
            foreach (var t in Zone.BoundThreads)
            {
                switch (t.BoundaryType)
                {
                    case BoundaryTypes.FluidWall:
                        WallDistance.SetBound_Wall(i1);
                        break;
                    case BoundaryTypes.Symmetry:
                    case BoundaryTypes.VelocityInlet:
                    case BoundaryTypes.PressureInOut:
                        WallDistance.SetBound_NotWall(i1);
                        break;
                    default:
                        LxConsole.Error("未识别的边界类型");
                        break;
                }
                i1++;
            }
            SetParameter_kw();
        }
    }
}
//public void SetWallDisPDE()
//{
//    ScalarOfLaplaceEquation walldis = WallDistance.MakePDECalulator();
//    SolverControl.WallDisGroup.PDEDistance.AddWallDisCal(WallDistance,  walldis);
//}
//walldis.setBoundary_fixValue(new Value1Const(0), i1, t);
//walldis.setBoundary_fixFlux(new Value1Const(0), i1, t);
// new ScalarOfSteadyDiffusion();
//walldis.CreateScalar(zone);
//walldis.setZone(new Value1Const(1), new Value1Const(1), new Value1Const(0), 1);
//int i1 = 0;
//foreach (var t in zone.BoundThreads)
//{
//    switch (t.boundaryType)
//    {
//        case BoundaryTypes.流体壁面:
//            walldis.setBoundary_fixValue(new Value1Const(0), i1, t);
//            break;
//        case BoundaryTypes.对称:
//        case BoundaryTypes.速度入口:
//        case BoundaryTypes.压力出入口:
//            walldis.setBoundary_fixFlux(new Value1Const(0), i1, t);
//            break;
//        default:
//            MainViewModel.mainViewModel.log.AddWithTime("未识别的边界类型");
//            break;
//    }
//    i1++;
//}
//walldis.SetMultiGridAAtLast(zone.AMGSolver.MGLocal_A);
